package com.jcommander.utils;

import java.net.URL;

import javax.swing.Icon;
import javax.swing.ImageIcon;

public class ImageLoader {

	private static ImageLoader IMAGE_LOADER;
	
	public static ImageLoader getInstance() {
		return IMAGE_LOADER == null ? new ImageLoader() : IMAGE_LOADER;
	}
	
	private ImageLoader() {}
	
	public Icon loadImage(String path) {
		URL imgURL = getClass().getResource(path);
        if (imgURL != null) {
            return new ImageIcon(imgURL);
        } else {
            System.err.println("Couldn't find file: " + path);
                return null;
        }
	}
	
}
